{include="header"}

<script type="text/javascript">
   function eliminar(name)
   {
      if( confirm("¿Realmente desea eliminar este plugin?") )
      {
         window.location.href = '{$fsc->url()}&delete='+name;
      }
   }
</script>

<div class="container-fluid" style="margin-top: 10px;">
   <div class="row">
      <div class="col-md-9">
         <h2 style="margin-top: 0px;">Plugins</h2>
      </div>
      <div class="col-md-3">
         <form class="form" action="https://www.facturascripts.com/store/" target="_blank">
            <input type="hidden" name="post_type" value="product"/>
            <div class="input-group">
               <input type="text" name="s" class="form-control">
               <span class="input-group-btn">
                  <button class="btn btn-primary" type="button">
                     <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
                  </button>
               </span>
            </div>
         </form>
      </div>
   </div>
</div>

<div class="visible-sm visible-xs" style="margin-bottom: 10px;">
</div>

<div role="tabpanel">
   <ul class="nav nav-tabs" role="tablist">
      {if condition="$fsc->unstables"}
      <li><a href="{$fsc->url()}">Estables</a></li>
      <li role="presentation" class="active">
         <a href="#home" aria-controls="home" role="tab" data-toggle="tab">
            <span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span> &nbsp; Inestables
         </a>
      </li>
      {else}
      <li role="presentation" class="active">
         <a href="#home" aria-controls="home" role="tab" data-toggle="tab">Estables</a>
      </li>
      <li>
         <a href="{$fsc->url()}&unstable=TRUE">
            <span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span> &nbsp; Inestables
         </a>
      </li>
      {/if}
      <li role="presentation">
         <a href="#store" aria-controls="store" role="tab" data-toggle="tab">Más...</a>
      </li>
   </ul>
   <div class="tab-content">
      <div role="tabpanel" class="tab-pane active" id="home" style="margin-top: 10px;">
         <div class="container-fluid">
            <div class="row">
               <div class="col-md-6">
               <!--{$total=count($fsc->plugins())}-->
               {loop="$fsc->plugins()"}
                  <div class="panel{if condition="$value['enabled']"} panel-success{else} panel-default{/if}">
                     <div class="panel-heading">
                        <h3 class="panel-title">
                           {if condition="$fsc->unstables"}
                           <span class="glyphicon glyphicon-warning-sign" aria-hidden="true" title="Esta plugin está en desarrollo y puede dar probemas"></span> &nbsp;
                           {/if}
                           {$value['name']}
                        </h3>
                     </div>
                     <div class="panel-body">
                        <div class="pull-right">
                        {if condition="$fsc->unstables"}
                           {if condition="$value['enabled']"}
                           <a class="btn btn-sm btn-danger" type="button" value="Desactivar" title="Desactivar" href="{$fsc->url()}&unstable=TRUE&disable={$value['name']}">
                              <span class="glyphicon glyphicon-remove"></span> &nbsp; Desactivar
                           </a>
                           {else}
                           <div class="btn-group">
                              <a class="btn btn-sm btn-default" type="button" value="Activar" title="Activar" href="{$fsc->url()}&unstable=TRUE&enable={$value['name']}">
                                 <span class="glyphicon glyphicon-ok"></span> &nbsp; Activar
                              </a>
                              <a class="btn btn-sm btn-default" onclick="eliminar('{$value['name']}')" title="eliminar plugin">
                                 <span class="glyphicon glyphicon-trash"></span>
                              </a>
                           </div>
                           {/if}
                        {else}
                           {if condition="$value['enabled']"}
                           <a class="btn btn-sm btn-danger" type="button" value="Desactivar" title="Desactivar" href="{$fsc->url()}&disable={$value['name']}">
                               <span class="glyphicon glyphicon-remove"></span> &nbsp; Desactivar
                           </a>
                           {else}
                           <div class="btn-group">
                              <a class="btn btn-sm btn-default" type="button" value="Activar" title="Activar" href="{$fsc->url()}&enable={$value['name']}">
                                  <span class="glyphicon glyphicon-ok"></span> &nbsp; Activar
                              </a>
                              <a class="btn btn-sm btn-default" onclick="eliminar('{$value['name']}')" title="eliminar plugin">
                                 <span class="glyphicon glyphicon-trash"></span>
                              </a>
                           </div>
                           {/if}
                        {/if}
                        </div>
                        <div>{$value['description']}</div>
                     </div>
                  </div>
                  {if condition="$counter+1==intval($total/2)"}
                  </div><div class="col-md-6">
                  {/if}
               {/loop}
               </div>
            </div>
         </div>
      </div>
      <div role="tabpanel" class="tab-pane" id="store">
         <div class="container-fluid" style="margin-top: 10px;">
            <div class="row">
               <div class="col-md-4">
                  <div class="panel panel-default">
                     <div class="panel-heading">
                        <h3 class="panel-title">Subir plugin</h3>
                     </div>
                     <div class="panel-body">
                        <p>Si tienes un plugin en un archivo .zip, puedes subirlo e instalarlo desde aquí.</p>
                        <form class="form" action="{$fsc->url()}" enctype="multipart/form-data" method="post">
                           <input type="hidden" name="install" value="TRUE"/>
                           <div class="form-group">
                              <input type="file" name="fplugin" accept="application/zip"/>
                           </div>
                           <button type="submit" class="btn btn-default">
                              <span class="glyphicon glyphicon-import" aria-hidden="true"></span> &nbsp; Instalar
                           </button>
                        </form>
                     </div>
                  </div>
               </div>
               <div class="col-md-4">
                  <div class="panel panel-default">
                     <div class="panel-heading">
                        <h3 class="panel-title">Tienda de plugins</h3>
                     </div>
                     <div class="panel-body">
                        <p>Consigue más plugins en la tienda oficial de plugins de FacturaScripts.</p>
                        <a href="https://www.facturascripts.com/store/" target="_blank" class="btn btn-primary">
                           <span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span> &nbsp; Tienda oficial
                        </a>
                     </div>
                  </div>
               </div>
               <div class="col-md-4">
                  <div class="panel panel-default">
                     <div class="panel-heading">
                        <h3 class="panel-title">¿Necesitas una personalización?</h3>
                     </div>
                     <div class="panel-body">
                        <p>Podemos crearte uno a medida. Para que FacturaScripts se adapte exáctamente a lo que buscas, y no al contrario.</p>
                        <a href="//www.facturascripts.com/community/premium.php" target="_blank" class="btn btn-info">
                           <span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> &nbsp; Personalizar
                        </a>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </div>
</div>

{include="footer"}